{include file="public/header" /}
<body>
<style>
    .cion{
        display: inline-block;
        width: 120px;
    }
</style>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 商品管理
    <span class="c-gray en">&gt;</span> 出售列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="/good/order_sell" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form  method="get" action="">
        <div class="text-c">
            <input type="text" class="input-text" style="width:250px" placeholder="订单号" value="{:input('word')}" name="word">
            <span class="select-box" style="width: 100px;">
                <select name="type" class="select">
                    <option value="-1">类型</option>
                    <option value="1" {if isset($_GET['type']) && $_GET['type'] == 1}selected{/if}>平台放单</option>
                    <option value="2" {if isset($_GET['type']) && $_GET['type'] == 2}selected{/if}>换购订单</option>
                    <option value="3" {if isset($_GET['type']) && $_GET['type'] == 3}selected{/if}>用户订单</option>
                </select>
            </span>
            <span class="select-box" style="width: 100px;">
                <select name="gid" class="select">
                    <option value="0">全部商品</option>
                    {foreach $goods as $v}
                        {if isset($_GET['gid']) && $v.id ==  $_GET['gid']}
                        <option value="{$v.id}" selected>{$v.name}</option>
                        {else/}
                        <option value="{$v.id}">{$v.name}</option>
                        {/if}
                    {/foreach}

                </select>
            </span>
            <button type="submit" class="btn btn-success">搜索</button>
        </div>
    </form>

    <div class="cl pd-5 bg-1 bk-gray mt-20">
        <span class="l">
        </span>
        <span class="r">共有数据：<strong>{$list->total()}</strong> 条</span> </div>
    <table class="table table-border table-bordered table-hover table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="11">出售列表</th>
        </tr>
        <tr class="text-c">
            <th width="30">id</th>
            <th width="100">订单号</th>
            <th width="50">类型</th>
            <th width="80">用户</th>
            <th width="150">商品</th>
            <th width="150">接盘信息</th>
            <th width="80">创建时间</th>
            <th width="80">正常到期</th>
            <th width="80">预计到期</th>
            <th width="100">状态</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        {foreach $list as $v}
        <tr class="text-c">
            <td>{$v.id}</td>
            <td>{$v.sn}</td>
            <td>{switch name="$v.type"}
                {case value="1"}平台放单{/case}
                {case value="2"}换购订单{/case}
                {case value="3"}用户订单{/case}
                {default /}--
                {/switch}</td>
            <td>{$v.uid}-{$v.user_name}-{$v.mobile}</td>
            <td>{$v.gname}-(mt:{$v.mt}-收益:{$v.day_profit})/{$v.days}天</td>
            <td>{$v.next_sn}-{$v.next_user_name}</td>
            <td>{$v.create_time}</td>
            <td>{$v.end_time}</td>
            <td>{$v.estimate}</td>
            <td>{switch name="$v.status"}
                {case value="1"}收益中{/case}
                {case value="2"}已匹配{/case}
                {case value="3"}取消重卖{/case}
                {case value="4"}申诉重卖{/case}
                {case value="5"}已销毁{/case}
                {case value="6"}判定重卖{/case}
                {case value="7"}完成{/case}
                {case value="8"}判定终止{/case}
                {default /}--
                {/switch}</td>
            </td>
            <td>
                {if $v.status == 1 || $v.status == 3 || $v.status == 4  }
                <span class="label label-success radius" onclick="order_destroy(this,{$v.id})">
                        强制匹配</span>
                {/if}

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    <div class="page">
        {$list->render()|raw}
    </div>
</div>

{include file="public/footer" /}

<script type="text/javascript">

    function panding(obj,id){
        var info = '确认要 判定吗，判定之后将冻结接盘人，此订单将重新挂卖？';
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('order_trial')}",
                data: {id:id},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }

    function order_destroy(obj,id){
        var info = '确认要 销毁吗，销毁之后，此订单将终止收益的继续匹配？';
        layer.confirm(info,function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('order_destroy')}",
                data: {id:id},
                dataType: 'json',
                success: function(data){
                    if(data.status == 'y'){
                        layer.msg("操作成功",{icon:1,time:1000,shade: [0.3, '#000']},function(){
                            location.replace(location.href);
                        });
                    }else{
                        layer.msg(data.info,{icon:2,time:1000,shade: [0.3, '#000']});
                    }
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
</script>